<?php
/**
  *  @package ARXLib
  *  @version 2
  *  @subpackage Inputs
  *
  *  @copyright Ringo-Web Inc. 2004 - 2005
  */
//////////////////////////////////////////////////////////////////////////////////////
// CARXRichEditTinyMCE
//////////////////////////////////////////////////////////////////////////////////////
class CARXRichEditTinyMCE   extends   CARXInput
{
	var $mSimple;

	function CARXRichEditTinyMCE($label, $dbFieldName, $simple = false, $width = 40, $height = 20)
	{
		parent::CARXInput($label, $dbFieldName);
		$this->m_width = $width;
		$this->m_height = $height;
		$this->m_password = $isPassword;
		$this->m_align = $align;
		$this->mSimple = $simple;
	}

	function GetHTML()
	{
		// Get cms language
		/* $cmsSettingsTable = new CARXTable("cms_settings");
		$cmsSettingsTable->SetMode(1, 0);
		$cmsSettings = $cmsSettingsTable->FetchRows();
		$cmsSettings = $cmsSettings[0];
		$cmsLanguageId = $cmsSettings['language_id'];
		$languagesTable = new CARXTable("cms_languages", "language_id={$cmsLanguageId}", "sign");
		$cmsLanguage = $languagesTable->FetchRows();
		$cmsLanguage = substr($cmsLanguage[0]['sign'], 0, 2); */
		
		
		//$result = parent::GetHTML();
		//$htmlCtrlName = $this->GetHTMLCtrlName();
		$value = htmlspecialchars($this->m_value, ENT_QUOTES);

		if ($this->m_height == 1)
		{
			$result = "<input type=\"text\" name=\"{$this->m_dbFieldName}\" value=\"$value\" size=\"$this->m_width\"$this->m_TagParams>\n";
		}
		else
		{
			$arxurl = ARX_LIB_URL;

			if ($GLOBALS['tinymce_set'] == true)
			{
				$scriptTop = '';
			}
			else
			{
				$GLOBALS['tinymce_set'] = true;

				if ($this->mSimple)
				{
					$scriptTop = <<< eoc
<!-- tinyMCE -->
<script language="javascript" type="text/javascript" src="/cms/libs/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
<script language="javascript" type="text/javascript">
	tinyMCE.init({
		mode : "specific_textareas",
		textarea_trigger : "convert_this",
		
		convert_urls : true,
		relative_urls : false,
		remove_script_host : true,
		remove_linebreaks : false,
		verify_html : false,
		fix_content_duplication : false,
		remove_linebreaks : false,
		apply_source_formatting : true,
		
		theme : "simple",
		onchange_callback : "changeToUnsaved"
	});
</script>
<!-- /tinyMCE -->
eoc;
}
else
{
	$scriptTop = <<< eoc
<!-- Commercial plugins -->
<script language="javascript" type="text/javascript" src="/cms/libs/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
<script language="javascript" type="text/javascript" src="/cms/libs/tinymce/imagemanager/jscripts/mcimagemanager.js"></script>
<!-- /Commercial plugin -->
<!-- tinyMCE -->
<script language="javascript" type="text/javascript" src="/cms/libs/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
<script language="javascript" type="text/javascript">
	// Notice: The simple theme does not use all options some of them are limited to the advanced theme
	   tinyMCE.init({

                        mode : "textareas",

                        theme : "advanced",

                        skin : "o2k7",

                        plugins : "safari,spellchecker,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,pagebreak,imagemanager,filemanager",

                        theme_advanced_buttons1_add_before : "save,newdocument,separator",

                        theme_advanced_buttons1_add : "fontselect,fontsizeselect",

                        theme_advanced_buttons2_add : "separator,insertdate,inserttime,preview,separator,forecolor,backcolor",

                        theme_advanced_buttons2_add_before: "cut,copy,paste,pastetext,pasteword,separator,search,replace,separator",

                        theme_advanced_buttons3_add_before : "tablecontrols,separator",

                        theme_advanced_buttons3_add : "emotions,iespell,media,advhr,separator,print,separator,ltr,rtl,separator,fullscreen",

                        theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,spellchecker,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage",

                        theme_advanced_toolbar_location : "top",

                        theme_advanced_toolbar_align : "left",

                        theme_advanced_statusbar_location : "bottom",

                        content_css : "/example_data/example_full.css",

                plugin_insertdate_dateFormat : "%Y-%m-%d",

                plugin_insertdate_timeFormat : "%H:%M:%S",

                        extended_valid_elements : "hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style],p[lang]",

                        external_link_list_url : "example_data/example_link_list.js",

                        external_image_list_url : "example_data/example_image_list.js",

                        flash_external_list_url : "example_data/example_flash_list.js",

                        template_external_list_url : "example_data/example_template_list.js",

                        theme_advanced_resize_horizontal : false,

                        theme_advanced_resizing : true,

                        apply_source_formatting : true,

                        relative_urls:false,
                        spellchecker_languages : "+English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr,German=de,Italian=it,Polish=pl,Portuguese=pt,Spanish=es,Swedish=sv"

            });


</script>
<!-- /tinyMCE -->
eoc;
}
			}
			$result = $scriptTop."
				<textarea id=\"{$this->m_dbFieldName}\" name=\"{$this->m_dbFieldName}\" rows=\"$this->m_height\" cols=\"$this->m_width\"$this->m_TagParams convert_this=\"true\">$value</textarea>\n
				".$scriptBottom;
		}
		return $result;
	}
}

?>